package edu.wkd.towave.memorycleaner.model;

import android.graphics.drawable.Drawable;

/**
 * Created by towave on 2016/5/15.
 */
public class AppProcessInfo implements Comparable<AppProcessInfo> {
    /**
     * The app name.
     */
    public String appName;

    /**
     * The name of the process that this object is associated with.
     */
    public String processName;

    /**
     * The pid of this process; 0 if none.
     */
    public int pid;

    /**
     * The user id of this process.
     */
    public int uid;

    /**
     * The icon.
     */
    public Drawable icon;

    /**
     * 占用的内存.
     */
    public long memory;

    /**
     * 占用的内存.
     */
    public String cpu;

    public String packName;

    /**
     * 进程的状态，其中S表示休眠，R表示正在运行，Z表示僵死状态，N表示该进程优先值是负数.
     */
    public String status;

    /**
     * 当前使用的线程数.
     */
    public String threadsCount;

    public boolean checked = true;

    /**
     * 是否是系统进程.
     */
    public boolean isSystem;


    /**
     * Instantiates a new ab process info.
     */
    public AppProcessInfo() {
        super();
    }


    /**
     * Instantiates a new ab process info.
     *
     * @param processName the process name
     * @param pid the pid
     * @param uid the uid
     */
    public AppProcessInfo(String processName, int pid, int uid) {
        super();
        this.processName = processName;
        this.pid = pid;
        this.uid = uid;
    }


    @Override public int compareTo(AppProcessInfo another) {
        if (this.processName.compareTo(another.processName) == 0) {
            if (this.memory < another.memory) {
                return 1;
            }
            else if (this.memory == another.memory) {
                return 0;
            }
            else {
                return -1;
            }
        }
        else {
            return this.processName.compareTo(another.processName);
        }
    }
}
